/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

/**
 * <p>Project: jse2204 - Format3
 * <p>Powered by webrx On 2022-08-30 11:23:23
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Format3 {
    public static void main(String[] args) {
        System.out.printf("%05d%n",6244);
        System.out.printf("%5d%n",6);
        System.out.printf("%-5d%n",6);
        System.out.printf("%d%n",6);
        String name = "李四";
        int age = 18;
        String address = "河南省郑州市科学大道88号";
        System.out.println("姓名：" + name + "，年龄：" + age + "岁，地址：" + address + "。");

        //格式化输出
        System.out.printf("姓名：%s，年龄：%d岁，地址：%s。", name, age, address);

        System.out.println(); //ffoo3o
        //%s 字符串   %d 十进制数字 %f 小数 %t 时间 %x  %<   %1$
        System.out.printf("%d %<x %<02x %<X %4$x",255,"a","b",55);
        //255 ff ff FF 05
        System.out.println();

        //格式化小数
        System.out.printf("%.0f  %<.2f   %<.1f  %<.3f  %.0f",.12589,.958);

        System.out.println();

        System.out.printf("%.2f%n",80d);


        //Locale.setDefault(Locale.US);
        //格式日期时间
        Date d = new Date();
        Calendar c = Calendar.getInstance();
        System.out.println(d.getTime());
        System.out.println(c.getTimeInMillis());
        System.out.println();
        System.out.printf("%tF %<tT%n",c);
        System.out.printf("%tF %<tT%n",d);
        System.out.printf("%tF%n",d);
        System.out.printf("%tT%n",d);
        System.out.printf("%tA %n",d);
        System.out.printf("%tY年%<tm月%<td日%n",d);
        //2022年08月30日 18时48分 星期二
    }
}
